#include <iostream>
#include "matrixUtilities.h"

using namespace std;


int main(int argc, char **argv) {
	if (argc != 2) {
		cout << "Usage: " << argv[1] << " dim" << endl;
		return 0;
	}

	unsigned int n = atoi(argv[1]);

	int *matrix = (int *) malloc(n * n * sizeof(int));
	if (matrix == NULL) {
		cout << "Allocate matrix buffer error!" << endl;
		return 0;
	}

	unsigned int i, j;
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			matrix[i * n + j] = i * n + j;
		}
	}

	cout << "Matrix before rotation:" << endl;
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			cout << matrix[i * n + j] << "\t";
		}
		cout << endl;
	}
	cout << endl << endl;

	rotateMatrix(matrix, n);
	cout << "Matrix after rotation:" << endl;
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			cout << matrix[i * n + j] << "\t";
		}
		cout << endl;
	}
	cout << endl << endl;

	cout << "Matrix content:" << endl;
	printMatrix(matrix, n);

	setRowColumnZeros(matrix, n, n);

	cout << "After setting zeros, matrix content:" << endl;
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			cout << matrix[i * n + j] << "\t";
		}
		cout << endl;
	}
	cout << endl << endl;


	free(matrix);

	return 0;
}

